﻿using Base.FileRemoteModel.UpFile;
using Base.FileRemoteModel.UserFile;
using Base.FileRemoteModel.UserFile.Model;
using Base.FileService.Interface;
using WeDonekRpc.Client.Interface;
using WeDonekRpc.SqlSugarDbTran.Attr;

namespace Base.FileService.RpcEvent
{
    internal class UserFileEvent : IRpcApiService
    {
        private readonly IUserFileService _Service;

        public UserFileEvent ( IUserFileService service )
        {
            this._Service = service;
        }
        public void CopyUserFile ( CopyUserFile obj )
        {
            this._Service.Copy(obj.Files);
        }
        public UserFileStream GetFileStream ( GetFileStream obj )
        {
            return this._Service.GetStream(obj.FileId);
        }
        public UserFileDatum[] GetUserFileList ( GetUserFileList obj )
        {
            return this._Service.GetFiles(obj.Param);
        }
        public void ToVoidUserFile ( ToVoidUserFile obj )
        {
            this._Service.ToVoid(obj.FileId);
        }
        public void RestoreUserFile ( RestoreUserFile obj )
        {
            this._Service.Restore(obj.FileId);
        }
        public void DropFileById ( DropFileById obj )
        {
            this._Service.Drop(obj.FileId);
        }
        public UserFileData[] GetUserFiles ( GetUserFiles obj )
        {
            return this._Service.GetFiles(obj.LinkPk, obj.LinkType, obj.Tag);
        }
        public void BatchDropFileById ( BatchDropFileById obj )
        {
            this._Service.Drop(obj.Ids);
        }
        public void BatchDropFile ( BatchDropFile obj )
        {
            this._Service.Drop(obj.DirKey, obj.LinkBizPk);
        }
        public void SaveFile ( SaveFile obj )
        {
            this._Service.SaveFile(obj.FileId, obj.LinkBizPk, obj.DropFileId);
        }
        [RpcDbTransaction]
        public void SaveFileList ( SaveFileList obj )
        {
            this._Service.SaveFile(obj.FileId, obj.LinkBizPk, obj.DropFileId);
        }
        public void DropFile ( DropFile obj )
        {
            this._Service.Drop(obj.DirKey, obj.LinkBizPk, obj.Tag);
        }
    }
}
